<?php

namespace app\index\validate\test;

use ShidianUtil\Thinkphp\Validate\BaseValidate;

/**
 * Class Test
 * @package app\index\validate\test
 * @link https://www.kancloud.cn/manual/thinkphp6_0/1037623
 * @see \app\index\controller\test\Test
 */
class Test extends BaseValidate
{

    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'id'	=> 'isId',
		'payMethod'	=> 'scalar|max:16',
		'orderNo'	=> 'scalar|max:64',
		'tradeNid'	=> 'scalar|max:64',
		'describe'	=> 'scalar|max:255',
		'transferType'	=> 'scalar|max:32',
		'transferTypeClass'	=> 'scalar|max:255',
		'totalMoney'	=> 'numeric|egt:0',
		'totalNum'	=> 'integer|egt:0|max:10',
		'successNum'	=> 'integer|egt:0|max:10',
		'updated'	=> 'integer|max:11',
		'created'	=> 'integer|max:11',
        'page'      => 'integer|egt:0|max:11',
        'page_size' => 'integer|egt:0|max:11',
    ];

    protected $field = [
        'id'	=> 'id',
		'payMethod'	=> 'payMethod',
		'orderNo'	=> 'orderNo',
		'tradeNid'	=> 'tradeNid',
		'describe'	=> 'describe',
		'transferType'	=> 'transferType',
		'transferTypeClass'	=> 'transferTypeClass',
		'totalMoney'	=> 'totalMoney',
		'totalNum'	=> 'totalNum',
		'successNum'	=> 'successNum',
		'updated'	=> 'updated',
		'created'	=> 'created',
        'page'      => '分页页数',
        'page_size' => '分页大小',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
        'id.require'	=> '缺少:attribute',
		'id.isId'	=> '请设置正确的:attribute',
		'payMethod.require'	=> '请输入:attribute',
		'payMethod.scalar' => ':attribute应该是字符串',
		'payMethod.max'	=> ':attribute长度不能超过:rule位',
		'orderNo.require'	=> '请输入:attribute',
		'orderNo.scalar' => ':attribute应该是字符串',
		'orderNo.max'	=> ':attribute长度不能超过:rule位',
		'tradeNid.require'	=> '请输入:attribute',
		'tradeNid.scalar' => ':attribute应该是字符串',
		'tradeNid.max'	=> ':attribute长度不能超过:rule位',
		'describe.require'	=> '请输入:attribute',
		'describe.scalar' => ':attribute应该是字符串',
		'describe.max'	=> ':attribute长度不能超过:rule位',
		'transferType.require'	=> '请输入:attribute',
		'transferType.scalar' => ':attribute应该是字符串',
		'transferType.max'	=> ':attribute长度不能超过:rule位',
		'transferTypeClass.require'	=> '请输入:attribute',
		'transferTypeClass.scalar' => ':attribute应该是字符串',
		'transferTypeClass.max'	=> ':attribute长度不能超过:rule位',
		'totalMoney.require'	=> '请输入:attribute',
		'totalMoney.numeric' => ':attribute应该是数字',
		'totalMoney.egt'	=> ':attribute应该大于等于:rule',
		'totalNum.require'	=> '请输入:attribute',
		'totalNum.integer' => ':attribute应该是整数',
		'totalNum.egt'	=> ':attribute应该大于等于:rule',
		'totalNum.max'	=> ':attribute长度不能超过:rule位',
		'successNum.require'	=> '请输入:attribute',
		'successNum.integer' => ':attribute应该是整数',
		'successNum.egt'	=> ':attribute应该大于等于:rule',
		'successNum.max'	=> ':attribute长度不能超过:rule位',
		'updated.require'	=> '请输入:attribute',
		'updated.integer' => ':attribute应该是整数',
		'updated.max'	=> ':attribute长度不能超过:rule位',
		'created.require'	=> '请输入:attribute',
		'created.integer' => ':attribute应该是整数',
		'created.max'	=> ':attribute长度不能超过:rule位',
        'page.require'      => '请输入:attribute',
        'page.integer'      => ':attribute应该是整数',
        'page.egt'          => ':attribute应该大于等于:rule',
        'page.max'          => ':attribute长度不能超过:rule位',
        'page_size.require' => '请输入:attribute',
        'page_size.integer' => ':attribute应该是整数',
        'page_size.egt'     => ':attribute应该大于等于:rule',
        'page_size.max'     => ':attribute长度不能超过:rule位',
    ];

    protected $scene = [
        'delete' => ['id' => 'require'],
        'index'  => ['page', 'page_size'],
        'read'   => ['id' => 'require'],
        'save'   => ['payMethod', 'orderNo', 'tradeNid', 'describe', 'transferType', 'transferTypeClass', 'totalMoney', 'totalNum', 'successNum', 'updated', 'created'],
    ];

}
